package com.icode.core.model.house;

import com.icode.core.model.AbstractEntity;
import com.icode.core.model.user.User;
import org.joda.time.LocalDate;

import javax.persistence.*;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: xianfei
 * Date: 15-10-29
 * Time: 上午10:43
 * To change this template use File | Settings | File Templates.
 */
@Table(name = "rent")
@Entity
public class Rent extends TrusteeshipDetails {

    @ManyToOne
    @JoinColumn(name = "my_house_id")
    private MyHouse myHouse;
    private String days;

    @Column(name = "my_house_status")
    @Enumerated(EnumType.STRING)
    private MyHouseStatus myHouseStatus;

    @OneToOne
    @JoinColumn(name="user_id")
    private User lessee;

    @Embedded
    private CustomerInfo customerInfo;

    public Rent() {
    }

    public Rent(MyHouse myHouse, String price, String days, String description, String leaveDate, String checkInDate) {
        this.myHouse = myHouse;
        super.setPrice(price);
        super.setDescription(description);
        super.setLeaveDate(leaveDate);
        super.setCheckInDate(checkInDate);
        this.days = days;
        this.customerInfo = new CustomerInfo();
    }

    public Rent(MyHouse myHouse, String price, String days, String description, String leaveDate, String checkInDate, MyHouseStatus myHouseStatus) {
        this.myHouse = myHouse;
        super.setPrice(price);
        super.setDescription(description);
        super.setLeaveDate(leaveDate);
        super.setCheckInDate(checkInDate);
        this.days = days;
        this.myHouseStatus = myHouseStatus;
        this.customerInfo = new CustomerInfo();
    }

    public MyHouse myHouse() {
        return myHouse;
    }

    public String days() {
        return days;
    }

    public CustomerInfo customerInfo() {
        return customerInfo;
    }

    public MyHouseStatus myHouseStatus() {
        return myHouseStatus;
    }

    public void update(String customer, String phoneNum, String description,String coustomerNum,boolean noticeWay) {
        this.customerInfo=new CustomerInfo(customer,phoneNum,description,coustomerNum,noticeWay);
    }

    public void update(User user, MyHouseStatus status) {
        this.lessee=user;
        this.myHouseStatus=status;
//        this.myHouse.initMyHouseStatus(status);
    }
}
